﻿using JetBrains.Annotations;
using Microsoft.Extensions.Caching.Distributed;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace Xms.Abp.Caching;

public interface IHashCache<TCacheItem>
{
    Task RefreshAsync(bool? hideErrors = null, CancellationToken cancellationToken = default);
    Task RemoveAsync(bool? hideErrors = null, CancellationToken cancellationToken = default);
    Task<bool> ExistsAsync(CancellationToken cancellationToken = default);
    Task<DistributedCacheEntryOptions> GetExpirationFromCache(CancellationToken cancellationToken = default);
    Task<bool> FieldExsitsAsync(string field, CancellationToken cancellationToken = default);
    Task<TCacheItem> GetAsync([NotNull] string field, bool? hideErrors = null, bool considerUow = false, CancellationToken cancellationToken = default);
    Task<KeyValuePair<string, TCacheItem>[]> GetManyAsync(IEnumerable<string> fields, bool? hideErrors = null, bool considerUow = false, CancellationToken cancellationToken = default);
    Task<KeyValuePair<string, TCacheItem>[]> GetAllAsync(bool? hideErrors = null, bool considerUow = false, CancellationToken cancellationToken = default);
    Task<IEnumerable<string>> GetFieldsAsync(CancellationToken cancellationToken = default);
    Task<TCacheItem> GetOrAddAsync([NotNull] string field, Func<Task<TCacheItem>> factory, bool? hideErrors = null, bool considerUow = false, CancellationToken cancellationToken = default);
    Task RemoveAsync([NotNull] string field, bool? hideErrors = null, bool considerUow = false, CancellationToken cancellationToken = default);
    Task SetAsync([NotNull] string field, [NotNull] TCacheItem value, bool? hideErrors = null, bool considerUow = false, CancellationToken cancellationToken = default);
    Task SetManyAsync(IEnumerable<KeyValuePair<string, TCacheItem>> items, bool? hideErrors = null, bool considerUow = false, CancellationToken cancellationToken = default);
}

//public interface IHashDistributedCache<TCacheItem, TOptions> : IHashDistributedCache<TCacheItem>
//    where TCacheItem : class
//    where TOptions : XmsCacheOptions
//{
//}
